<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>focus-within</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        .form {
            border: 2px solid #52bb82;
            padding: 8px;
            border-radius: 2px;
            margin: 8px;
        }
        .form:focus-within {
            background-color: #7cf0bd;
        }
        .form:focus-within .label {
            color:#fff;
        }
        .label {
            width: 72px;
            display: inline-block;
        }
        .input {
            margin: 4px 12px;
            border: 1px solid #59595a;
            border-radius: 4px;
            padding: 8px 16px;
            outline: none;
        }
    </style>
</head>
<body>
    <form class="form">
        <label for="username" class="label">Username:</label>
        <input type="text" id="username" class="input">
        <br>
        <label for="password" class="label">Password:</label>
        <input type="text" id="password" class="input">
    </form>
</body>
</html>